/**
 * Created by liubin on 2015/09/18.
 */
'use strict';

import React from 'react';

export default class ValidateComponent extends React.Component {
    // 获取validation
    getValidation(field) {
        if (field.touched) {
            if (field.invalid) {
                return 'error';
            } else {
                return 'success';
            }
        } else {
            return '';
        }
    }
    getSuccess(field) {
        if (field.touched) {
            if (!field.invalid) {
                return true;
            }
        }
        return false;
    }
    getError(field) {
        if (field.touched) {
            if (field.invalid) {
                return true;
            }
        }
        return false;
    }
    // 获取message
    getMessage(field) {
        if (field.touched) {
            if (field.invalid) {
                return field.error;
            } else {
                return '';
            }
        } else {
            return '';
        }
    }
}